<template>
  <div id="outside">
    <div id="inside">
      <a ref="test" href="https://www.baidu.com" target="_blank">去百度</a>
    </div>
  </div>
</template>

<script>

export default {
  name: 'App',
  mounted() {
    // useCapture 是否是捕获的时候就触发事件
    document.addEventListener('click', function () {
      console.log('capture')
    }, {
      capture: false // 捕获的时候是否就触发事件
    })
    document.addEventListener('click', function () {
      console.log('false')
    }, true)

    this.$refs.test.addEventListener('click', function (e) {
      console.log('click a')
      e.preventDefault()
    }, {
      capture: true,
      passive: false // 是否禁用preventDefault
    })
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
